#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
const int N=1e5+50;
const int M=1e6+50;
const int INF=0x3f3f3f3f;
int T,n,m;
int pi,si,ei;
int s,t;
int cnt;
int head[N],dep[N],cur[N];
struct Edge{
    int u,v,w,next;
}edge[M];
void init(){
    cnt=0;
    memset(head,-1,sizeof(head));
}
void addEdge(int u,int v,int w){
    edge[cnt]=Edge{u,v,w,head[u]};
    head[u]=cnt++;
    edge[cnt]=Edge{v,u,0,head[v]};
    head[v]=cnt++;
}   
bool bfs(){
    memset(dep,0,sizeof(dep));
    queue<int> q;
    q.push(s);
    dep[s]=1;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=head[u];i!=-1;i=edge[i].next){
            int v=edge[i].v;
            int w=edge[i].w;
            if(w>0 && dep[v]==0){
                dep[v]=dep[u]+1;
                q.push(v);
            }
        }
    }
    return dep[t]!=0;
}
int dfs(int u,int flow){
    if(u==t){
        return flow;
    }
    for(int &i=cur[u];i!=-1;i=edge[i].next){
        int v=edge[i].v;
        int w=edge[i].w;
        if(dep[v]==dep[u]+1 && w!=0){
            int dis=dfs(v,min(w,flow));
            if(dis>0){
                edge[i].w-=dis;
                edge[i^1].w+=dis;
                return dis;
            }
        }
    }
    return 0;
}
int Dinic(){
    int ans=0;
    while(bfs()){
        for(int i=0;i<=t;i++){
            cur[i]=head[i];
        }
        while(int d=dfs(s,INF)){
            ans+=d;
        }
    }
    return ans;
}
int main(void){
    int c=1;
    scanf("%d",&T);
    while(T--){
        init();
        scanf("%d%d",&n,&m);
        int sum=0;
        int Max=0;
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&pi,&si,&ei);
            sum+=pi;
            Max=max(Max,ei);
            //源点与任务
            addEdge(0,i,pi);
            for(int j=si;j<=ei;j++){
                //任务和日期
                addEdge(i,n+j,1);
            }
        }
        s=0;
        t=Max+n+1;
        for(int i=1;i<=Max;i++){
            //日期和汇点
            addEdge(n+i,t,m);
        }   
        int ans=Dinic();
        if(ans==sum){
            printf("Case %d: Yes\n",c++);
        }
        else{
            printf("Case %d: No\n",c++);
        }
        printf("\n");
    }
    return 0;
}